home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / uucp / protocol / hanrahan.paper < prev    next >
Encoding:
Internet Message Format  |  1991-08-18  |  50.0 KB

  1. Path: clarkson!rpi!sarah!cs.albany.edu!psinntp!iggy.GW.Vitalink.COM!lll-winken!uunet!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!ucsd!nosc!crash!simpact!cmkrnl!jeh
  2. From: jeh@cmkrnl.uucp
  3. Newsgroups: comp.mail.uucp
  4. Subject: Re: G protocol
  5. Message-ID: <1991Aug4.154551.190@cmkrnl.uucp>
  6. Date: 4 Aug 91 22:45:51 GMT
  7. References: <4682@se-sd.SanDiego.NCR.COM> <231@s5000.rsvl.unisys.com> <1991Aug2.012529.10008@uunet.uu.net>
  8. Organization: Kernel Mode Consulting, San Diego CA
  9. Lines: 1377
  10.  
  11. In article <1991Aug2.012529.10008@uunet.uu.net>, ziegast@uunet.UU.NET 
  12. (Eric W. Ziegast) writes:
  13. > A good doc on G protocol that I've seen is:
  14. >     UUCP "G" PROTOCOL by Jamie E. Hanrahan
  15. > I suppose that if there's enough response to this, it will be posted
  16. > again.  If you mail jeh, I suppose you'd be mailed a copy.  I dunno.
  17.  
  18. Ok, here it is again.  I've also submitted it to comp.doc, so it should be
  19. archived there soon. 
  20.  
  21. As always, comments, criticisms, additions, etc., ARE WELCOME.  
  22.  
  23. I've made a couple of tweaks to be able to send this through mail and news. 
  24. Before printing, use a text editor to do the following:
  25.  
  26.     o  Change all occurrences of the string ^L (two characters, 
  27.     a carat and an uppercase L) to a form-feed character
  28.  
  29.     o  Change all occurrences of the string ^H to a backspace
  30.     character (this is used in underlined sequences)
  31.  
  32. Let me know if I can answer any questions.
  33.  
  34.     --- Jamie Hanrahan, Kernel Mode Consulting, San Diego CA
  35. uucp protocol guru, VMSnet (DECUS uucp) Working Group, and
  36. Chair, VMS Internals Working Group, U.S. DECUS VAX Systems SIG 
  37. Internet:  jeh@dcs.simpact.com, hanrahan@eisner.decus.org, or jeh@crash.cts.com
  38. Uucp:  ...{crash,eisner,uunet}!cmkrnl!jeh
  39.  
  40. ^L
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                            UUCP "G" PROTOCOL
  58.  
  59.  
  60.                              Session UN047
  61.  
  62.                        Fall 1990 DECUS Symposium
  63.  
  64.                            Las Vegas, Nevada
  65.  
  66.  
  67.                             Tuesday, 4pm-5pm
  68.  
  69.                       Pavilion 2, Las Vegas Hilton
  70.  
  71.  
  72.  
  73.                            Jamie E. Hanrahan
  74.         Chair, VMSnet (DECUS uucp) and Internals Working Groups
  75.                          DECUS VAX Systems SIG
  76.  
  77.                            Simpact Associates
  78.                           9210 Sky Park Court
  79.                           San Diego, CA 92123
  80.                          +1 619-565-1865 x1116
  81.                           jeh@dcs.simpact.com
  82.                            jeh@crash.cts.com
  83.                  {decwrl,scubed,crash,nosc}!simpact!jeh
  84. ^L
  85. UUCP "G" PROTOCOL                                                 Page 2
  86. UN047, Tuesday, 4-5 pm
  87.  
  88.  
  89. 1  INITIAL HANDSHAKE ("SHERE EXCHANGE")
  90.  
  91.  
  92.       o  Occurs after call placement and login
  93.  
  94.       o  Initiated by answering system
  95.  
  96.       o  All messages begin with \020 (ctrl-P, also known as DLE) and
  97.          end with \000 (NUL)
  98.  
  99.       o  Sent and received in "raw mode" (no carriage returns, line
  100.          feeds, etc.)
  101.  
  102.           ______________________________________________________________
  103.  
  104.           Caller                                                Answerer
  105.           ------>                                              <--------
  106.  
  107.           (places call, gets carrier,
  108.           gets login prompt, logs in)
  109.                                                  (uucico program starts)
  110.                                                   \020Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He\000
  111.           \020S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He\000
  112.                                                              \020ROK\000
  113.           ______________________________________________________________
  114.  
  115.  
  116.       o  _^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He's are the respective systems' uucp host names.
  117.  
  118.       o  Caller's S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He message may include any or all of the
  119.          following optional elements:
  120.  
  121.          S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He -Q_^Hs_^He_^Hq -x_^Hd_^Hb_^Hg -p_^Hg_^Hr_^Ha_^Hd_^He -vgrade=_^Hg_^Hr_^Ha_^Hd_^He
  122.  
  123.           -  _^Hs_^He_^Hq = call sequence number (or 0)
  124.  
  125.           -  _^Hd_^Hb_^Hg is a digit, answerer sets its debug level accordingly
  126.  
  127.           -  _^Hg_^Hr_^Ha_^Hd_^He indicates what class of files are being transferred
  128.              (e.g. mail, news, arbitrary files).  Taken from systems
  129.              file entry; not sent or supported by all systems.  Some
  130.              implementations support -p, some support -v, some both,
  131.              some neither.  (See discussion of "C." files later on)
  132.  
  133.       o  Old answerers may send just Shere instead of Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He .
  134.  
  135. The "ROK" message says that the answerer has accepted the call.
  136. Instead, the answerer may reject the call with any of the following
  137. messages:
  138.  
  139.       o  RLCK - answerer thinks it's already talking to that caller
  140.  
  141.       o  RCB - answerer wants to call the caller back (to avoid imposter
  142.          callers)
  143. ^L
  144. UUCP "G" PROTOCOL                                                 Page 3
  145. UN047, Tuesday, 4-5 pm
  146.  
  147.  
  148.       o  RBADSEQ - call sequence number is wrong (caller is an imposter,
  149.          or more likely, sequence numbers weren't updated properly at
  150.          one end or the other)
  151.  
  152.       o  RLOGIN - caller's login name (username) isn't known to
  153.          answerer's uucp (USERFILE or Permissions file)
  154.  
  155.       o  RYou are unknown to me - (yes, it really does send all of that)
  156.          caller's hostname isn't known to answerer (as determined by
  157.          L.sys or Systems file)
  158.  
  159. If caller receives any of these, it simply hangs up.  (The answerer
  160. hangs up after sending the reject message, possibly waiting a few
  161. seconds so that the modem disconnect won't prevent the message from
  162. reaching the caller.)
  163.  
  164. If answerer "accepts the call":
  165.  
  166.           ______________________________________________________________
  167.  
  168.           Caller                                                Answerer
  169.           ------>                                              <--------
  170.  
  171.                                                                P_^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht
  172.           U_^Hp_^Hr_^Ho_^Ht
  173.           ______________________________________________________________
  174.  
  175.  
  176. where
  177.  
  178.       o  _^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht is a list of the protocols (each identified by a
  179.          single letter, e.g. "g") supported by the answerer
  180.  
  181.       o  _^Hp_^Hr_^Ho_^Ht is a single protocol from _^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht selected by the
  182.          answerer
  183.  
  184.       o  Caller can send UN (and then hang up) if it supports no
  185.          protocols in common with answerer
  186.  
  187. At this point the two machines have agreed on a protocol.  We'll assume
  188. that it's the "g" protocol, so that the last two messages may have been
  189. something like
  190.  
  191.           ______________________________________________________________
  192.  
  193.           Caller                                                Answerer
  194.           ------>                                              <--------
  195.  
  196.                                                                     Pfgt
  197.           Ug
  198.           ______________________________________________________________
  199.  
  200.  
  201. At this point both systems call the gturnon() function, which causes the
  202. g data link protocol to start up.
  203. ^L
  204. UUCP "G" PROTOCOL                                                 Page 4
  205. UN047, Tuesday, 4-5 pm
  206.  
  207.  
  208. 2  G PROTOCOL PACKET FORMATS
  209.  
  210. All subsequent communication (until after the G protocol shutdown) is in
  211. "packet mode".
  212.  
  213.       o  Each packet has a six-byte header
  214.  
  215.       o  Control packets have _^Ho_^Hn_^Hl_^Hy a header
  216.  
  217.       o  Data packets have a header and a data segment
  218.  
  219.  
  220. 2.1  Packet Header Format
  221.  
  222.           +-------+-------+-------+-------+-------+-------+
  223.           |  DLE  |   K   | cklo  | ckhi  |  ctl  |  XOR  |
  224.           +-------+-------+-------+-------+-------+-------+
  225.  
  226. The first byte is _^Ha_^Hl_^Hw_^Ha_^Hy_^Hs DLE (octal 020, hex 10).
  227.  
  228. The second byte is the "K-byte".  For a control packet it is always 9
  229. (ie a tab character).  For data packets it indicates the transmitted
  230. (physical) length of the following data segment, as follows:
  231.  
  232.                 K-byte value    data seg. len. (bytes)
  233.                 ------------    ----------------------
  234.                       1                   32
  235.                       2                   64
  236.                       3                  128
  237.                       4                  256
  238.                       5                  512
  239.                       6                 1024
  240.                       7                 2048
  241.                       8                 4096
  242.                       9             control packet
  243.  
  244.  
  245. The third and fourth bytes are the low and high bytes, respectively, of
  246. a checksum computed on the data segment (if any) plus the control byte.
  247. (The checksum computation is described later.)
  248.  
  249. The fifth byte is a bitmapped command byte, described in the next
  250. section.
  251.  
  252. The last byte is a simple XOR of the middle four bytes.  The first and
  253. last bytes perform a framing and validation function for headers.
  254.  
  255.  
  256. 2.2  The Control Byte
  257.  
  258. The "control" byte is bit-mapped as follows:
  259.  
  260.                   7   6   5   4   3   2   1   0
  261.                 +-------+-----------+-----------+
  262.                 | T   T | X   X   X | Y   Y   Y |
  263.                 +-------+-----------+-----------+
  264. ^L
  265. UUCP "G" PROTOCOL                                                 Page 5
  266. UN047, Tuesday, 4-5 pm
  267.  
  268.  
  269. The T field denotes the type of packet:
  270.  
  271.         T value         packet type
  272.         -------         ------------------------------------------
  273.            0            control packet 
  274.            1            alternate channel data packet (unused in uucp)
  275.            2            long data block
  276.            3            short data block (to be described later)
  277.  
  278. The interpretations of the X and Y fields vary with the packet type
  279. (control vs. data).
  280.  
  281. For control packets the X field is the type of control packet and the Y
  282. field is a parameter, as follows:
  283.  
  284.         X value    name      Y field interpretation
  285.         -------    ------    ---------------------------------------
  286.            1       CLOSE     no significance
  287.            2       NAK       last correctly received packet number
  288.            3       SRJ       packet number to retransmit
  289.            4       ACK       last correctly received packet number
  290.            5       INITC     max window size to use
  291.            6       INITB     max data segment size to use
  292.            7       INITA     max window size to use
  293.  
  294.  
  295.       o  The "data segment size" on the INITB packet is encoded like the
  296.          KBYTE but with numbers one lower; e.g. an INITB packet with a Y
  297.          field of 1 indicates a data segment size of 64 bytes.
  298.  
  299.       o  Most descriptions of uucp refer to types 2 and 4 as "RJ"
  300.          (reject) and "RR" (receiver ready), respectively.
  301.  
  302.       o  SRJ ("selective reject") is not used in known implementations.
  303.  
  304.  
  305. 2.3  Data Packets
  306.  
  307. For data packets, the X field is the sequence number of the packet, and
  308. the Y field is the "ACK number" -- the sequence number of the last
  309. packet correctly received by the system sending the data packet.  (See
  310. the section on data transfer and acknowledgement.)
  311.  
  312. A data packet header is always followed by a data segment of size
  313. indicated by the Kbyte.
  314.  
  315.  
  316. 2.3.1  Long Data Packets
  317.  
  318. If the packet type is "long data", all 'n' bytes of the data segment
  319. (where 'n' is denoted by the Kbyte) contain data.
  320. ^L
  321. UUCP "G" PROTOCOL                                                 Page 6
  322. UN047, Tuesday, 4-5 pm
  323.  
  324.  
  325. 2.3.2  Short Data Packets
  326.  
  327. If the packet type is "short data", the data segment is still sent in
  328. its entirety, but the first one or two bytes indicate the _^Hd_^Hi_^Hf_^Hf_^He_^Hr_^He_^Hn_^Hc_^He
  329. between its physical (transmitted) length and the number of bytes to be
  330. passed to the presentation level (its "logical length"):
  331.  
  332.  
  333.       7   6   5   4   3   2   1   0
  334.     +---+---------------------------+
  335.     | 0 | length difference (1-127) |
  336.     +---+---------------------------+
  337.  
  338.     or, if the difference is too large to fit in seven bits,
  339.  
  340.       7   6   5   4   3   2   1   0   7   6   5   4   3   2   1   0
  341.     +---+---------------------------+-------------------------------+
  342.     | 1 | length difference(lo bits)| length difference (high bits) |
  343.     +---+---------------------------+-------------------------------+
  344.         first byte of data segment     second byte of data segment
  345.  
  346.  
  347. For example, a data packet with a physical segment size of 64 (Kbyte=2),
  348. but an effective (logical) length of zero, would be sent by sending a
  349. "short data" packet where the data segment consisted of a byte with the
  350. numeric value 64, e.g.
  351.  
  352.  
  353.       7   6   5   4   3   2   1   0
  354.     +---+---------------------------+
  355.     | 0 | 1   0   0   0   0   0   0 |
  356.     +---+---------------------------+
  357.  
  358.  
  359. followed by 63 additional bytes (whose contents would be ignored by the
  360. receiver).
  361.  
  362.  
  363. 3  G PROTOCOL ("DATA LINK LAYER") INITIALIZATION
  364.  
  365. G protocol is initialized via an exchange of the INITA, INITB, and INITC
  366. packets.  A simple approach:
  367.  
  368.       o  Each system starts sending INITA's to the other
  369.  
  370.       o  Upon receiving an INITA, send an INITB
  371.  
  372.       o  Upon receiving an INITB, send an INITC
  373.  
  374.       o  When both have sent and received an INITC, initialization is
  375.          complete
  376.  
  377. When the INITx packets are received each system sets its uucp parameters
  378. (data segment size and maximum transmit window size) to the _^Hs_^Hm_^Ha_^Hl_^Hl_^He_^Hr of
  379. what it can handle and what it gets from the packet.
  380. ^L
  381. UUCP "G" PROTOCOL                                                 Page 7
  382. UN047, Tuesday, 4-5 pm
  383.  
  384.  
  385. 4  G PROTOCOL DATA TRANSFER AND ACKNOWLEDGEMENT
  386.  
  387. After initialization, data packets are exchanged.  Thus, all subsequent
  388. traffic consists of Shortdata, Longdata, ACK, and NAK packets (until the
  389. end of the session, when CLOSE packets are exchanged).
  390.  
  391.       o  Each data packet must be _^Ha_^Hc_^Hk_^Hn_^Ho_^Hw_^Hl_^He_^Hd_^Hg_^He_^Hd by the receiver.
  392.  
  393.       o  Data packets can only be acknowledged in sequence.
  394.  
  395.       o  If a data packet arrives corrupted (as determined via
  396.          checksum), the receiver sends a NAK (requesting retransmission)
  397.          or simply does not send an ACK, allowing the sender to time out
  398.          awaiting an ACK (which has the same effect).
  399.  
  400.       o  The first packet sent by each transmitter has sequence number
  401.          one.  Packet sequence numbers are modulo 8 (ie 1, 2, ..., 7, 0,
  402.          1, ...)
  403.  
  404.       o  Uucp (in most implementations) uses a transmit window size of
  405.          more than 1 (typically 3, maximum 7 due to the three-bit packet
  406.          sequence numbers)
  407.  
  408.           -  After sending one data packet the sender need not wait for
  409.              an ACK before sending the next data packet, until _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw
  410.              _^Hs_^Hi_^Hz_^He unACK'd packets have been sent
  411.  
  412.           -  Colloquially this is known as a "windowed" protocol.  (As
  413.              opposed to stop-and-wait, e.g. most Kermit implementations)
  414.  
  415.           -  After the transmit window is full (ie _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw _^Hs_^Hi_^Hz_^He unACK'd
  416.              packets have been sent), transmitter must wait for an ACK
  417.              of (at least) the first packet in the transmit window
  418.              before sending another packet
  419.  
  420.       o  g protocol's _^Hr_^He_^Hc_^He_^Hi_^Hv_^He _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw _^Hs_^Hi_^Hz_^He is 1 -- at any given time
  421.          there is only one packet which is valid to be received.
  422.  
  423.       o  An ACK provides the number of the last correctly-received
  424.          packet, and implies that all earlier packet numbers have also
  425.          been correctly received.  Thus a single ACK may acknowledge
  426.          multiple packets.
  427.  
  428.       o  The "ACK number" -- the number of the most recent correctly-
  429.          received message -- also appears in the Y field of the headers
  430.          of data packets.  If a system is about to acknowledge a packet,
  431.          but happens to have a data packet to send, it need not send an
  432.          explicit ACK; putting the number of the packet to be ACK'd in
  433.          the Y field of the data packet is sufficient.  This doesn't
  434.          happen often, because uucp's "upper layers" don't use the link
  435.          in both directions at once.
  436.  
  437.       o  A NAK provides _^Ht_^Hh_^He _^Hs_^Ha_^Hm_^He _^Hn_^Hu_^Hm_^Hb_^He_^Hr as an ACK but requests
  438.          retransmission of all outstanding packets with higher (modulo
  439.          8) numbers.
  440. ^L
  441. UUCP "G" PROTOCOL                                                 Page 8
  442. UN047, Tuesday, 4-5 pm
  443.  
  444.  
  445.       o  Both ACKs and NAKs provide acknowledgement for not only the
  446.          indicated packet but also all previous packets in the transmit
  447.          window ("stacked ACKs").
  448.  
  449. This is known as a "go back n" protocol.  It is relatively easy to
  450. implement but performance suffers when errors occur.
  451.  
  452. More complex protocols allow a receive window size of greater than one
  453. with "selective reject", and this was in fact the intent of the SRJ
  454. control packet.  An SRJ says "retransmit this one packet, I didn't get
  455. it right".  This avoids having to resend an entire transmit window to
  456. correct an error in just one packet.
  457. ^L
  458. UUCP "G" PROTOCOL                                                 Page 9
  459. UN047, Tuesday, 4-5 pm
  460.  
  461.  
  462. 4.1  A Simple Data Exchange
  463.  
  464.           ______________________________________________________________
  465.  
  466.           Sender                                                Receiver
  467.           ------>                                              <--------
  468.  
  469.           Data 1 
  470.                                                     (receives Data 1 ok)
  471.                                                                    Ack 1
  472.           Data 2
  473.                                                     (receives Data 2 ok)
  474.                                                                    Ack 2
  475.           (receives Ack 1)
  476.           Data 3
  477.                                                     (receives Data 3 ok)
  478.                                                                    Ack 3
  479.           (receives Ack 2)
  480.           Data 4
  481.                                               (receives Data 4 in error)
  482.                                                                    NAK 3
  483.           (receives Ack 3)
  484.           Data 5
  485.                                     (receives Data 5 ok but out of seq.)
  486.           (receives NAK 3)
  487.           (resends everything in window)
  488.           Data 4
  489.           Data 5
  490.                                                     (receives Data 4 ok)
  491.                                                                    Ack 4
  492.           Data 6
  493.                                                     (receives Data 5 ok)
  494.                                                                    Ack 5
  495.           (receives Ack 4)
  496.           Data 7
  497.                                       etc...
  498.           ______________________________________________________________
  499.  
  500.  
  501. 4.2  Data Link Layer:  Interesting Cases, Implementation Notes, And War
  502.      Stories
  503.  
  504. 4.2.1  Corrupted Packet Headers
  505.  
  506. When looking for a packet, the receiver should scan for a DLE, then read
  507. the next five bytes following and check the XOR.
  508.  
  509.       o  If the XOR check fails, the "packet header" cannot be trusted.
  510.          Scanning for the next DLE begins at the next byte following the
  511.          current DLE (_^Hn_^Ho_^Ht six bytes after it).
  512.  
  513.       o  If the XOR check succeeds, but something's wrong with the
  514.          header (illegal Kbyte value, for example), the receiver should
  515.          treat this the same as an XOR failure.  (XOR checks aren't all
  516.          that robust)
  517. ^L
  518. UUCP "G" PROTOCOL                                                Page 10
  519. UN047, Tuesday, 4-5 pm
  520.  
  521.  
  522. 4.2.2  Corrupted Data Segments
  523.  
  524. If the header on a data packet is good (XOR is okay), but the checksum
  525. indicates that the data segment is corrupt:
  526.  
  527.       o  Send a NAK to indicate receipt of a corrupted data packet (but
  528.          see below)
  529.  
  530.       o  Rescan the input looking for the next control packet, starting
  531.          with the first byte of the data segment
  532.  
  533. This seems counterintuitive; if we can trust the header it seems that we
  534. ought to be able to trust it to tell us how long the data segment is,
  535. and just skip it.
  536.  
  537. Suppose the file being received is a copy of just one direction of a
  538. uucp data transfer.  If we pay no attention to what's inside the data
  539. segments we see this (assuming 32-byte data segments, K = 1):
  540.  
  541.  
  542.         HHHHHH DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD HHHHHH DDDD...
  543.  
  544.         but since the data contains a uucp packet stream, the data 
  545.         fields contain
  546.  
  547.         HHHHHH ddddhhhhhhdddddddddddddddddddddd HHHHHH ddddddddddhhhhhh
  548.                                                                
  549.         1          2                            3          4     5
  550.  
  551.  
  552. Now, suppose that the header at 1 gets corrupted in transmission, so the
  553. XOR check fails.  We junk it and start looking for another DLE, and we
  554. find the "imbedded header" at 2.  It passes xor, so we interpret it as a
  555. data header, and read the next 32 characters.  If it happens to be the
  556. right packet number it'll fail on checksum, but more likely it's the
  557. wrong packet number; whatever, we send a NAK to tell the sender what we
  558. want, and resume scanning.  Since we rescan all of (what we thought was)
  559. the data segment, we'll find the DLE at 3...and we're back in sync.
  560.  
  561. If instead we had said "bad data segment, skip 32 characters" we'd be
  562. looking for the next header starting at 4.  We'd then find the next
  563. imbedded header at 5....  we'd eventually get back in sync, but it might
  564. take a LONG time!
  565.  
  566.  
  567. 4.2.3  Missing Packets (out-of-sequence Packets)
  568.  
  569. Uucp "g" protocol employs a receive window size of one; that is, there
  570. is only one packet that may be received at any time (the next one that
  571. follows the previous correctly-received packet).
  572.  
  573. If an out-of-sequence packet is received the correct response is to send
  574. a NAK (with the Y field, as always, being the number of the last good
  575. packet).
  576. ^L
  577. UUCP "G" PROTOCOL                                                Page 11
  578. UN047, Tuesday, 4-5 pm
  579.  
  580.  
  581. 4.2.4  Too Many NAKs
  582.  
  583. It is not good to send a NAK for every error condition.  Let's revisit
  584. the simple data exchange diagrammed previously:
  585.  
  586.           ______________________________________________________________
  587.  
  588.           Sender                                                Receiver
  589.           ------>                                              <--------
  590.  
  591.           Data 3
  592.                                                     (receives Data 3 ok)
  593.                                                                    Ack 3
  594.           (receives Ack 2)
  595.           Data 4
  596.                         (data 4 is corrupted on the link)
  597.                                                (receives Data 4 w/error)
  598.                                                               NAK 3 (#1)
  599.           (receives Ack 3)
  600.           Data 5
  601.                                            (receives Data 5 out of seq.)
  602.                                                               NAK 3 (#2)
  603.           Data 6
  604.                                            (receives Data 6 out of seq.)
  605.                                                               NAK 3 (#3)
  606.           (receives NAK 3 #1)
  607.           Data 4
  608.           Data 5
  609.           Data 6
  610.                                                     (receives Data 4 ok)
  611.                                                                    Ack 4
  612.           (receives NAK 3 #2)
  613.           Data 4
  614.           Data 5
  615.           Data 6
  616.           (receives Ack 4)
  617.                                            (receives Data 4 out of seq.)
  618.                                                                    NAK 4
  619.                                       etc...
  620.           ______________________________________________________________
  621.  
  622.  
  623.  
  624.       o  Unix uucps address this by being very "shy" about sending NAKs,
  625.          mostly just letting the sender time out.
  626.  
  627.          This works but hurts throughput.
  628.  
  629.       o  DECUS uucp keeps track of the number of received error packets
  630.          and sends the NAK only if the number modulo the window size =
  631.          1.  Thus we send the first NAK right away, but no more until at
  632.          least a window-size worth of packets have been received.
  633. ^L
  634. UUCP "G" PROTOCOL                                                Page 12
  635. UN047, Tuesday, 4-5 pm
  636.  
  637.  
  638. 4.2.5  Duplicate Packets
  639.  
  640. If a packet is received with a number that's already been received and
  641. ACKd it's either
  642.  
  643.       o  a duplicate of one we got earlier; our ACKs got lost, so the
  644.          sender timed out and is resending its window
  645.  
  646.       o  a future packet, and the intervening seven packets were bad
  647.          (but this can't happen, since max window size is seven, not
  648.          eight)
  649.  
  650. Since packets must always be acked in sequence, the only correct thing
  651. is to send a NAK indicating the last good (in sequence) received packet.
  652.  
  653.  
  654. 4.2.6  Miscellaneous
  655.  
  656. 4.2.6.1  Control Packet Priority
  657.  
  658. The control packet types denote the priority of the packets.  That is,
  659. if several control packets are to be sent, the lower-numbered ones are
  660. sent first.  (CLOSE before anything else, for example.) Control packets
  661. in turn have priority over data packets.
  662.  
  663.  
  664. 4.2.6.2  Varying Physical Packet Lengths
  665.  
  666. Although the protocol allows for data packets with different K values
  667. (physical lengths) to be sent in a session, in practice, both ends
  668. always use the value negotiated at the start of the session.
  669.  
  670.  
  671. 4.2.6.3  Interpacket Noise
  672.  
  673. The DLE that begins a packet should follow right on the heels of the
  674. previous packet.  Berkeley 4.3 uucp has a bug that causes it to send two
  675. null bytes between packets.  A robust implementation will _^Hn_^Ho_^Ht report
  676. errors when it encounters two null bytes while looking for a DLE.
  677.  
  678.  
  679. 4.2.6.4  Common Parameters
  680.  
  681. Almost all implementations seem to use a window size of 3 and a data
  682. packet physical length of 64 bytes (Kbyte = 2).  Some implementations
  683. will agree to use a larger window size or packet length, but do not do
  684. so correctly.
  685. ^L
  686. UUCP "G" PROTOCOL                                                Page 13
  687. UN047, Tuesday, 4-5 pm
  688.  
  689.  
  690. 4.2.6.5  Checksum Details
  691.  
  692. The checksum that is placed in the packet header for data packets has
  693. the value
  694.  
  695.                MAGIC - (chksum(buf,len) ^ (0xFF & cbyte))
  696.  
  697. For control packets, the checksum value is simply
  698.  
  699.                          MAGIC - (0xFF & cbyte)
  700.  
  701. where
  702.          buf is the data segment
  703.          len is its (physical) length
  704.          chksum() is shown below
  705.          cbyte is the value of the control byte
  706.          MAGIC is 0125252 (octal) (i.e. alternating bits set)
  707.  
  708. If a data packet is resent, the checksum must be recalculated, as the
  709. checksum includes the control byte and the Y field (last good received
  710. packet number) of the control byte might change between transmissions of
  711. the same data packet.
  712.  
  713. /*
  714.  * the checksum routine, copied from G. L. Chesson's article,
  715.  * modified by John Gilmore to reflect actual behavior 
  716.  * (see References)
  717.  */
  718.  
  719. int
  720. chksum(s,n)
  721. register unsigned char *s;
  722. register n;
  723. {
  724.         register short sum;
  725.         register unsigned short t;
  726.         register short x;
  727.  
  728.         sum = -1;
  729.         x = 0;
  730.         do {
  731.                 if (sum < 0) {
  732.                         sum <<= 1;
  733.                         sum++;
  734.                 }
  735.                 else
  736.                         sum <<= 1;
  737.                 t = sum;
  738.                 sum += *s++ & 0377;
  739.                 x += sum ^ n;
  740.                 if ((unsigned short)sum <= t)
  741.                         sum ^= x;
  742.         } while (--n > 0);
  743.  
  744.         return(sum);
  745. }
  746. ^L
  747. UUCP "G" PROTOCOL                                                Page 14
  748. UN047, Tuesday, 4-5 pm
  749.  
  750.  
  751. 5  FILE TRANSFER "MESSAGES" ("APPLICATION LAYER")
  752.  
  753. The data packets and acknowledgements form a _^Hr_^He_^Hl_^Hi_^Ha_^Hb_^Hl_^He _^Hd_^Ha_^Ht_^Ha _^Hl_^Hi_^Hn_^Hk which
  754. the two uucico programs use to exchange _^Hm_^He_^Hs_^Hs_^Ha_^Hg_^He_^Hs and _^Hf_^Hi_^Hl_^He_^Hs.
  755.  
  756. At the start of a uucp session the caller is in _^Hm_^Ha_^Hs_^Ht_^He_^Hr _^Hm_^Ho_^Hd_^He and the
  757. answerer is in _^Hs_^Hl_^Ha_^Hv_^He.  The caller searches its uucp spool directory for
  758. work (queued requests to send or receive files).  Each such "work
  759. request" results in an "S" (request to send), "R" (request to receive),
  760. or "X" (remote request for uucp) message being sent to the slave:
  761.  
  762.  
  763.         S _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hm_^Ha_^Hs_^Ht_^He_^Hr _^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hs_^Hl_^Ha_^Hv_^He ...
  764.  
  765.         R _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hs_^Hl_^Ha_^Hv_^He _^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hm_^Ha_^Hs_^Ht_^He_^Hr ...
  766.  
  767.         X _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He _^Hu_^Hu_^Hc_^Hp_^Hh_^Ho_^Hs_^Ht_^H!_^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He ...  (not covered here)
  768.  
  769.  
  770. The slave will respond with one of:
  771.  
  772.  
  773.             (for send requests)
  774.  
  775.         SY              ok
  776.         SN2             not permitted
  777.         SN4             can't create temporary file
  778.  
  779.             (for receive requests)
  780.  
  781.         RY<mode>        ok (gives protection mode of file)
  782.         RN2             not permitted
  783.  
  784.  
  785. If the master receives any of the reject messages it simply looks for
  786. its next queued work request.
  787.  
  788. If the master receives an "ok", the master (for file send requests) or
  789. the slave (for file receive requests) sends the file to the other side.
  790. The receiver of the file then sends one of the following messages:
  791.  
  792.  
  793.         CN5             couldn't move temp file into place
  794.         CY              file received ok
  795.  
  796.  
  797. to the sender.
  798. ^L
  799. UUCP "G" PROTOCOL                                                Page 15
  800. UN047, Tuesday, 4-5 pm
  801.  
  802.  
  803. 6  ROLE EXCHANGE
  804.  
  805. When the master has no more queued work requests it asks the slave if it
  806. wants to hang up.  The slave then looks for work and, if any is found,
  807. the two systems exchange master and slave roles.
  808.  
  809. Example:  Slave has no work, hangup is agreed upon:
  810.  
  811.           ______________________________________________________________
  812.  
  813.           Master                                                   Slave
  814.           ------>                                                 <-----
  815.  
  816.           H
  817.                                                                       HY
  818.           HY
  819.                         (at this point both systems invoke
  820.                          the G protocol shutdown routine)
  821.           ______________________________________________________________
  822.  
  823.  
  824.  
  825. Example:  Slave has work, roles are exchanged:
  826.  
  827.           ______________________________________________________________
  828.  
  829.           Master                                                   Slave
  830.           ------>                                                 <-----
  831.  
  832.           H
  833.                                                                       HN
  834.  
  835.                        (at this point roles are exchanged)
  836.           Slave                                                   Master
  837.           ----->                                                 <------
  838.  
  839.                                                        S file1 file2 ...
  840.  
  841.           ______________________________________________________________
  842.  
  843.  
  844. When the new master runs out of work it will again ask the former master
  845. if it wants to hang up (as more work may have been queued on that side
  846. during its tenure as slave).  The process repeats until neither system
  847. finds any work for the other.
  848. ^L
  849. UUCP "G" PROTOCOL                                                Page 16
  850. UN047, Tuesday, 4-5 pm
  851.  
  852.  
  853. 7  SENDING AND RECEIVING MESSAGES AND FILES ("PRESENTATION LAYER")
  854.  
  855. 7.1  Sending Messages
  856.  
  857.  
  858.       o  Messages (S, SY, SNn, R, RY, RNn, CY, CNn, H, HY, HN) are sent
  859.          in longdata packets.
  860.  
  861.       o  Some uucps send the last (or only) part of a message in a
  862.          shortdata packet.
  863.  
  864.       o  As many packets as necessary for the message are used.
  865.  
  866.       o  The message is terminated by a null byte.
  867.  
  868.       o  Only one message is sent at a time.
  869.  
  870.       o  Some uucps seem to expect the rest of the packet to be padded
  871.          with nulls.
  872.  
  873.  
  874. 7.2  Sending Files
  875.  
  876.  
  877.       o  Since Unix, and therefore uucp, has no concept of "file
  878.          attributes", the file is simply copied, byte for byte, into
  879.          packets and transmitted.  (The file protection mode is sent
  880.          either as a parameter on the S message or with the RY message.)
  881.  
  882.       o  Transmission of a shortdata packet with logical length of zero
  883.          indicates end of file (that is, the previous packet contains
  884.          the last bytes in the file).
  885.  
  886. These details are specific to the "g" protocol -- thus "g" includes both
  887. the data link and presentation layers.
  888.  
  889.  
  890. 8  G PROTOCOL SHUTDOWN
  891.  
  892. When both systems have agreed (via H, HY, HY message exchange) to hang
  893. up, they each call the gturnoff() function, causing CLOSE control
  894. messages to be exchanged:
  895.  
  896.           ______________________________________________________________
  897.  
  898.           (either)                                              (either)
  899.           -------->                                            <--------
  900.  
  901.                                                                    CLOSE
  902.           CLOSE
  903.           ______________________________________________________________
  904.  
  905.  
  906. ^L
  907. UUCP "G" PROTOCOL                                                Page 17
  908. UN047, Tuesday, 4-5 pm
  909.  
  910.  
  911. 9  "OVER AND OUT"
  912.  
  913. After the data link layer has exchanged "CLOSE" messages, one more set
  914. of "over and out" messages is exchanged:
  915.  
  916.           ______________________________________________________________
  917.  
  918.           Caller                                                Answerer
  919.           ------>                                              <--------
  920.  
  921.           OOOOOO  (six "O"'s)
  922.                                                   (seven "O"'s)  OOOOOOO
  923.           ______________________________________________________________
  924.  
  925.  
  926. Note that since the "g" protocol has already been turned off, these
  927. message are _^Hn_^Ho_^Ht preceded by six-byte headers.  They are, however,
  928. preceded by DLE and terminated by NUL, as were the Shere, S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He,
  929. P_^Hp_^Hr_^Ho_^Ht_^Hs, etc., messages at the beginning of the session.
  930. ^L
  931. UUCP "G" PROTOCOL                                                Page 18
  932. UN047, Tuesday, 4-5 pm
  933.  
  934.  
  935. 10  A COMPLETE SESSION
  936.  
  937. Here the caller sends one file and receives one, after which the
  938. answerer sends one file.  (ACKs, NAKs, and retransmits for the g
  939. protocol are not shown.)
  940.  
  941.           ______________________________________________________________
  942.  
  943.           Caller                                                Answerer
  944.           ------>                                              <--------
  945.  
  946.           (places call, logs in, etc.)
  947.                                                  (uucico program starts)
  948.  
  949.               (subsequent transmissions are framed by DLE .... NUL)
  950.  
  951.                                                           Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He
  952.           S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He
  953.                                                                      ROK
  954.                                                                     Pfgt
  955.           Ug
  956.  
  957.                   (subsequent packets have "g" protocol headers)
  958.  
  959.           Control(INITA)                                  Control(INITA)
  960.           Control(INITB)                                  Control(INITB)
  961.           Control(INITC)                                  Control(INITC)
  962.           Longdata(S fromfile1 tofile1 ...)
  963.                                                             Longdata(SY)
  964.           Longdata(file contents)
  965.           Longdata(file contents)
  966.                    ...
  967.           Shortdata(last few bytes of file)
  968.           Shortdata(logical length 0)
  969.                                                             Longdata(CY)
  970.           Longdata(R fromfile1 tofile1 ...)
  971.                                                             Longdata(RY)
  972.                                                  Longdata(file contents)
  973.                                                  Longdata(file contents)
  974.                                                           ...           
  975.                                        Shortdata(last few bytes of file)
  976.                                              Shortdata(logical length 0)
  977.           Longdata(CY)
  978.           Longdata(H)
  979.                                                             Longdata(HN)
  980.                                        Longdata(S fromfile1 tofile1 ...)
  981.           Longdata(SY)
  982.                                                  Longdata(file contents)
  983.                                                  Longdata(file contents)
  984.                                                           ...           
  985.                                        Shortdata(last few bytes of file)
  986.                                              Shortdata(logical length 0)
  987.           Longdata(CY)
  988.                                                              Longdata(H)
  989.           Longdata(HY)
  990.                                                             Longdata(HY)
  991. ^L
  992. UUCP "G" PROTOCOL                                                Page 19
  993. UN047, Tuesday, 4-5 pm
  994.  
  995.  
  996.           Control(CLOSE)                                  Control(CLOSE)
  997.  
  998.             (subsequent transmissions are framed only by DLE .... NUL)
  999.  
  1000.           OOOOOO
  1001.                                                                  OOOOOOO
  1002.           ______________________________________________________________
  1003.  
  1004.  
  1005.  
  1006.  
  1007. 11  UUCP WORK FILES:  ORIGINS OF "S" AND "R" COMMANDS
  1008.  
  1009. The uucico programs at each system are driven by _^Hw_^Ho_^Hr_^Hk _^Hf_^Hi_^Hl_^He_^Hs in the uucp
  1010. spool directory.
  1011.  
  1012.       o  To decide whether to call a uucp neighbor, uucico looks for
  1013.          work files associated with the neighbor's uucp host name.
  1014.  
  1015.       o  When answering a call from a uucp neighbor, after the neighbor
  1016.          asks "do you want to hang up?", the answering uucico looks for
  1017.          work files associated with the calling system's uucp host name.
  1018.  
  1019.  
  1020. 11.1  Work File Names
  1021.  
  1022. An older work file naming convention is:
  1023.  
  1024.         C._^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He _^Hg_^Hr_^Ha_^Hd_^He _^Hu_^Hn_^Hi_^Hq
  1025.  
  1026. For example,
  1027.  
  1028.         C.crashA8128
  1029.  
  1030.  
  1031.       o  "C." is a constant
  1032.  
  1033.       o  _^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He is the uucp host name of the remote system (7
  1034.          chars max, even if the actual host name is longer)
  1035.  
  1036.       o  _^Hg_^Hr_^Ha_^Hd_^He is a single letter denoting the priority of the work
  1037.          request
  1038.  
  1039.          e.g. "A" is the most important, "Z" is very unimportant, and
  1040.          "N" is somewhere in between.  Since the files are found by
  1041.          searching the spool directory, and since files are kept in
  1042.          lexical order by file name, the most important files are found
  1043.          first.
  1044.  
  1045.          Some uucps can be configured to only place outbound calls for
  1046.          certain grades of work at certain times of day; for example,
  1047.          mail is typically assigned a very high grade, and one might
  1048.          want to transfer mail almost as soon as it is queued, with file
  1049.          transfers somewhat less important, and news being relegated to
  1050.          evenings and nights.
  1051. ^L
  1052. UUCP "G" PROTOCOL                                                Page 20
  1053. UN047, Tuesday, 4-5 pm
  1054.  
  1055.  
  1056.       o  uniq is four characters (four digits in older implementations)
  1057.          which make this work file name unique, even though other work
  1058.          files for the same uucp host, with the same grade, may exist.
  1059.  
  1060.       o  Newer systems use four or six alphanumeric characters, and case
  1061.          _^Hi_^Hs significant, e.g. C.noscMabcdef is a different file from
  1062.          C.noscMabcdeF.
  1063.  
  1064.       o  Some Unix implementations use different conventions.
  1065.  
  1066.           -  HoneyDanBer uses a different subdirectory for each neighbor
  1067.              system (the subdirectory name is the neighbor system's uucp
  1068.              host name).  (see references)
  1069.  
  1070.           -  One implementation uses one subdirectory for "C." files,
  1071.              and another for all data files.
  1072.  
  1073.       o  Other systems with restrictive file names (e.g. MS-DOS) can use
  1074.          different conventions, as long as the same functions can be
  1075.          performed.  For example,
  1076.  
  1077.                  uucp/spool/C.simpactA1234
  1078.  
  1079.          might become
  1080.  
  1081.                  C:UUCP\SPOOL\C\SIMPACT\A1234
  1082.  
  1083. After starting up in master mode, the uucico program processes each work
  1084. file associated with the remote system.
  1085.  
  1086. When no work files remain, the master mode uucico offers to switch roles
  1087. (i.e. it sends an "H" message to the slave).  The slave searches for
  1088. work files containing the master's host name.  If any are found, roles
  1089. are switched, otherwise the systems agree to hang up.
  1090.  
  1091.  
  1092. 11.2  Work File Contents
  1093.  
  1094. Each work file contains one or more "S", "R", or "X" (not covered here)
  1095. commands.  These are processed (i.e. sent to the neighbor, and the
  1096. indicated file transferred) in turn.
  1097.  
  1098.  
  1099. 11.2.1  "S" (send File From Master To Slave) Commands
  1100.  
  1101. Format:
  1102.         S _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He _^Hu_^Hs_^He_^Hr _^Ho_^Hp_^Ht_^Hs _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He _^Hm_^Ho_^Hd_^He _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy
  1103.  
  1104.  
  1105.       o  _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He is the fully-qualified pathname of the source file
  1106.  
  1107.       o  _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He is the fully-qualified pathname to which the file is
  1108.          to be copied on the target system
  1109. ^L
  1110. UUCP "G" PROTOCOL                                                Page 21
  1111. UN047, Tuesday, 4-5 pm
  1112.  
  1113.  
  1114.       o  _^Hu_^Hs_^He_^Hr is the sending user's login name
  1115.  
  1116.       o  _^Ho_^Hp_^Ht_^Hs options, preceded by "-"
  1117.  
  1118.           -  c   send directly from _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He.  If absent, send from copy
  1119.              of file in spool directory, name given by _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He, and
  1120.              delete copy after transferring; in this case _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He is
  1121.              informational, providing the file's original name.
  1122.           -  m   notify sender by mail when copy is completed
  1123.           -  n   notify user _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy on target system when file arrives
  1124.  
  1125.          If no options are present, a hyphen appears here as a
  1126.          placeholder.
  1127.  
  1128.       o  _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He if "c" option present, "D.0"; if "c" absent, gives the
  1129.          name of the data file in the spool directory for uucico to
  1130.          send.
  1131.  
  1132.       o  _^Hm_^Ho_^Hd_^He is the Unix-style file protection mode (in octal) to be
  1133.          given to the new file
  1134.  
  1135.       o  _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy is the name of a user on the target system; present only
  1136.          if "n" option present
  1137.  
  1138.  
  1139. 11.2.2  "R" (Receive File From Slave To Master) Commands
  1140.  
  1141. Same as "S" commands, except _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He, _^Hm_^Ho_^Hd_^He, and _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy fields are not
  1142. present.
  1143.  
  1144.  
  1145. 11.3  Origins Of Work Files
  1146.  
  1147. Work files are created when:
  1148.  
  1149.       o  Users issue "uucp" commands
  1150.  
  1151.          (these are explicit requests to copy files to or from uucp
  1152.          neighbors)
  1153.  
  1154.       o  Users send mail which goes out via uucp
  1155.  
  1156.          (the "mailer" places the mail in a file in a spool directory,
  1157.          and creates the necessary work file to cause it to be sent to
  1158.          the first hop in the uucp path)
  1159.  
  1160.       o  "Route-through" uucp mail arrives
  1161.  
  1162.          (this is really just the same as the preceding case -- the
  1163.          "mailer" is seen as just another user)
  1164.  
  1165.       o  News is queued for transmission to another system
  1166.  
  1167.          (as with mail, the news transfer programs place the news batch
  1168.          in a file in the spool directory, and create the necessary work
  1169.          file)
  1170. ^L
  1171. UUCP "G" PROTOCOL                                                Page 22
  1172. UN047, Tuesday, 4-5 pm
  1173.  
  1174.  
  1175. 12  EXECUTION FILES ("X." FILES)
  1176.  
  1177. The X-file mechanism is used for _^Hr_^He_^Hm_^Ho_^Ht_^He _^Hc_^Ho_^Hm_^Hm_^Ha_^Hn_^Hd _^He_^Hx_^He_^Hc_^Hu_^Ht_^Hi_^Ho_^Hn.
  1178.  
  1179.       o  Receipt of a file named X.anything in the spool directory
  1180.          triggers the "uuxqt" program
  1181.  
  1182.       o  uuxqt interprets the X-file
  1183.  
  1184.       o  Typical uses are for mail and news
  1185.  
  1186.       o  The uux command allows users to request remote execution of
  1187.          arbitrary commands (permissions permitting)
  1188.  
  1189.  
  1190. 12.1  X-File Contents
  1191.  
  1192. The X-File contains one or more lines.  The first character on each line
  1193. specifies a command type.  It is followed by a blank and one or more
  1194. parameters which are interpreted according to the command type, as
  1195. follows:
  1196.  
  1197. (From a Usenet article by Dr. Peter Honeyman)
  1198.  
  1199.         C   command to be executed
  1200.         I   file name for command input
  1201.         O   file name for command output
  1202.         F   file required to be present before running command; optional
  1203.             second argument gives name for the file at execution time
  1204.         R   name of user who issued request (relative to the host named
  1205.             on the U line)
  1206.         U   second arg is name of host that passed this X. file to me;
  1207.             first arg is a user name on that host (overridden by R line)
  1208.         Z   send status notification (and error output) if command
  1209.             failed
  1210.         N   send no status notification if command failed
  1211.         n   send status notification if command succeeded
  1212.         B   return command input on error
  1213.         e   requests command be processed with sh(1)
  1214.         E   requests command be processed with exec(2)
  1215.         M   return status info to the named file on the requesting host
  1216.         #   comment line
  1217.  
  1218. Unrecognized lines are ignored, i.e. treated as comments.
  1219.  
  1220.  
  1221. 12.2  Example:  Sending Mail.
  1222.  
  1223. User jeh on system simpact sends mail to user bblue on uucp neighbor
  1224. crash.
  1225.  
  1226.      1.  simpact's mailer creates mail text file in spool directory
  1227.          (file name D.simpactA3214)
  1228. ^L
  1229. UUCP "G" PROTOCOL                                                Page 23
  1230. UN047, Tuesday, 4-5 pm
  1231.  
  1232.  
  1233.      2.  simpact's mailer creates what will become an X-file in
  1234.          simpact's spool directory (file name B.simpactA3214)
  1235.  
  1236.          U jeh simpact
  1237.          F D.simpactA3214
  1238.          I D.simpactA3214
  1239.          C rmail bblue
  1240.  
  1241.      3.  simpact's mailer creates work file in simpact's spool directory
  1242.          (file name C.crashA0001)
  1243.  
  1244.          S D.simpactA3214 D.simpactA3214 jeh - D.simpactA3214 0666
  1245.          S B.simpactA3214 X.simpactA3214 jeh - B.simpactA3214 0666
  1246.  
  1247.      4.  simpact calls system "crash" and interprets the work file,
  1248.          transferring the "D." and "B." files (in that order).
  1249.  
  1250.          Note that when the "B." file arrives at crash, its name is
  1251.          X.simpactA3214 (see the second "S" command in the C file
  1252.          above).
  1253.  
  1254.      5.  The uuxqt program at crash interprets the X file, using the
  1255.          file D.simpactA3214 as input to the command "rmail bblue".
  1256.  
  1257. Notes:
  1258.  
  1259.       o  Some systems use a different _^Hu_^Hn_^Hi_^Hq value in the file name for
  1260.          each locally-created file (instead of relying on the first
  1261.          letter to keep them separate).
  1262.  
  1263.       o  Some systems use the "D." prefix for both the mail message text
  1264.          and for the file that will become the "X." file on the target
  1265.          system.  (In this case, the _^Hu_^Hn_^Hi_^Hq value must be different for
  1266.          these two files)
  1267.  
  1268.       o  This mechanism is designed so that, even with a single spool
  1269.          directory and uncoordinated _^Hu_^Hn_^Hi_^Hq values, all file names will be
  1270.          unique:
  1271.  
  1272.           -  Only the local system creates "B." and "C." files.
  1273.  
  1274.           -  Only the remote system creates "X." files.
  1275.  
  1276.           -  Only the local system creates files called
  1277.              "D._^Hl_^Ho_^Hc_^Ha_^Hl_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He*".
  1278.  
  1279.           -  Only the remote system creates files called
  1280.              "D._^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He*".
  1281.  
  1282.  
  1283. 13  FILE NAME TRANSLATION
  1284.  
  1285. Systems with different file name syntax need not be barred from
  1286. participating in uucp transfers, and particularly not from mail and
  1287. news.
  1288. ^L
  1289. UUCP "G" PROTOCOL                                                Page 24
  1290. UN047, Tuesday, 4-5 pm
  1291.  
  1292.  
  1293. 13.1  Receiving Mail And News
  1294.  
  1295.  
  1296.       o  Only received "D." and "X." files are of concern.
  1297.  
  1298.       o  Local uucico maps file names specified by Unix system to local
  1299.          requirements when processing received "S" commands (in slave
  1300.          mode).
  1301.  
  1302.       o  Local uuxqt performs the _^Hs_^Ha_^Hm_^He translation when handling file
  1303.          names in the "X." file.
  1304.  
  1305.  
  1306. 13.2  Sending Mail And News
  1307.  
  1308.  
  1309.       o  Names of locally-created "B.", "C.", and "D." files can adhere
  1310.          to local conventions.
  1311.  
  1312.       o  When constructing the local work file ("C." file), build
  1313.          Unix-format _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He names in the "S" commands.
  1314.  
  1315.  
  1316. 14  REFERENCES AND ACKNOWLEDGEMENTS
  1317.  
  1318. 14.1  Uucp Protocols
  1319.  
  1320. (The following two papers were instrumental both in preparing this
  1321. article and in implement uucp "g" for VMS.  I believe that all of the
  1322. material in these two papers is incorporated in this article.  I could
  1323. be wrong.)
  1324.  
  1325. Chuck Wegrzyn posted a Usenet article (date unknown) that described the
  1326. Shere exchange, over-and-out exchange, and the application layer.
  1327.  
  1328. "Packet Driver Protocol" by G. L. Chesson of Bell Laboratories (October
  1329. 5, 1988), distributed via Usenet and Internet, is the standard reference
  1330. on the the "g" protocol data link layer.
  1331.  
  1332.  
  1333. 14.2  The Uucp System
  1334.  
  1335. _^HM_^Ha_^Hn_^Ha_^Hg_^Hi_^Hn_^Hg _^Hu_^Hu_^Hc_^Hp _^Ha_^Hn_^Hd _^HU_^Hs_^He_^Hn_^He_^Ht by Tim O'Reilly and Grace Todino, (O'Reilly And
  1336. Associates, Newton, MA 02164), has a good description of the Shere
  1337. exchange and of work file and execution file contents.
  1338.  
  1339. "Uucp Implementation Description" by D. A. Nowitz, part of most complete
  1340. Unix documentation sets (check the _^HS_^Hu_^Hp_^Hp_^Hl_^He_^Hm_^He_^Hn_^Ht_^Ha_^Hr_^Hy _^HD_^Ho_^Hc_^Hu_^Hm_^He_^Hn_^Ht_^Hs volumes, if
  1341. present) provides a general description of each program in the uucp
  1342. suite.
  1343.  
  1344. "HoneyDanBer UUCP -- Bringing UNIX Systems into the Information Age" by
  1345. Bill Rieken and Jim Webb, _^H;_^Hl_^Ho_^Hg_^Hi_^Hn_^H:  (journal of the Usenix Association),
  1346. Volume 11, Numbers 3 and 4 (May/June and July/August, 1986).  Describes
  1347. "external" features of one of the newest Unix uucp implementations,
  1348. including new file name conventions, logging, and error handling.
  1349. ^L
  1350. UUCP "G" PROTOCOL                                                Page 25
  1351. UN047, Tuesday, 4-5 pm
  1352.  
  1353.  
  1354. 14.3  General
  1355.  
  1356. A widely-recognized work on the subject of data communications protocols
  1357. is _^HC_^Ho_^Hm_^Hp_^Hu_^Ht_^He_^Hr _^HN_^He_^Ht_^Hw_^Ho_^Hr_^Hk_^Hs by Andrew S. Tanenbaum (Prentice-Hall).  Algorithms
  1358. are included for several different types of windowed data link
  1359. protocols.
  1360.  
  1361. _^HK_^He_^Hr_^Hm_^Hi_^Ht_^H, _^HA _^HF_^Hi_^Hl_^He _^HT_^Hr_^Ha_^Hn_^Hs_^Hf_^He_^Hr _^HP_^Hr_^Ho_^Ht_^Ho_^Hc_^Ho_^Hl by Frank da Cruz (Digital Press),
  1362. provides a very lucid description of the sliding-window extension to
  1363. Kermit.  Although windowed Kermit differs in several important ways from
  1364. uucp "g", this material was of great assistance in designing the
  1365. windowed "g" implementation for DECUS uucp and in understanding the
  1366. subtle nuances of windowed protocols.
  1367.  
  1368.  
  1369. 14.4  Critiques And Proofreading
  1370.  
  1371. The following people graciously reviewed and send comments on early
  1372. versions of this paper:
  1373.  
  1374.       o  Christopher J. Ambler, chris@fubarsys.slo.ca.us,
  1375.          cambler@polyslo.calpoly.edu
  1376.  
  1377.       o  Jordan Brown, jbrown@jato.jpl.nasa.gov
  1378.  
  1379.       o  Eric Johansson
  1380.  
  1381.       o  Nick Pemberton, Lsuc, uunet!mnetor!aimed!nick
  1382.  
  1383.       o  Mark Pizzolato, decwrl!infopiz!mark
  1384.  
  1385. (end)
  1386.